<?php
namespace app\patrol\controller;
use app\patrol\logic\BranchLogic;

/**
 * 分部api控制器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/09/06
 * Time: 16:22
 */
class Branch extends Base {

    public function __construct(){
        parent::__construct();
        $this->b_logic = new BranchLogic();
    }

    /**
     * 获取公用分部
     * @return \think\response\Json
     */
    public function ajax_get_public_branch(){
        $params = input();
        $r = $this->check_user_token($params);
        if($r['code'] != 1){
            return json($r);
        }

        //检查用户规则
        $r = $this->b_logic->check_user_rule();
        if($r['code'] != 1){
            return json($r);
        }

        $maps = $this->b_logic->get_search_public_branch_maps();
        $list = model('branch')->get_list($maps,'id,name');

        $data['list'] = $list;
        return json($this->b_logic->get_response(1,'OK',$data));
    }
}
